class BillingProfilesController < ApplicationController
  # GET /billing_profiles
  # GET /billing_profiles.xml
  def index
    @billing_profiles = BillingProfile.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @billing_profiles }
    end
  end

  # GET /billing_profiles/1
  # GET /billing_profiles/1.xml
  def show
    @billing_profile = BillingProfile.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @billing_profile }
    end
  end

  # GET /billing_profiles/new
  # GET /billing_profiles/new.xml
  def new
    @billing_profile = BillingProfile.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @billing_profile }
    end
  end

  # GET /billing_profiles/1/edit
  def edit
    basic_data
    @billing_profile = BillingProfile.find(params[:id])
  end

  # POST /billing_profiles
  # POST /billing_profiles.xml
  def create
    @billing_profile = BillingProfile.new(params[:billing_profile])
    # @profile = @billing_profile.profile_create

    respond_to do |format|
      if @billing_profile.save
        flash[:notice] = 'BillingProfile was successfully created.'
        format.html { redirect_to(@billing_profile) }
        format.xml  { render :xml => @billing_profile, :status => :created, :location => @billing_profile }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @billing_profile.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /billing_profiles/1
  # PUT /billing_profiles/1.xml
  def update
    basic_data
    @billing_profile = BillingProfile.find(params[:id])

    respond_to do |format|
      if @billing_profile.update_attributes(params[:billing_profile])
        flash[:notice] = 'BillingProfile was successfully updated.'
        format.html { redirect_to(@billing_profile) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @billing_profile.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /billing_profiles/1
  # DELETE /billing_profiles/1.xml
  def destroy
    @billing_profile = BillingProfile.find(params[:id])
    @billing_profile.destroy

    respond_to do |format|
      format.html { redirect_to(billing_profiles_url) }
      format.xml  { head :ok }
    end
  end
  
  def basic_data
    @statuses = BillingProfile.statuses
  end
end
